package ymr.game;

import java.util.ArrayList;
import java.util.List;

public class Tile {
	
	private Tile next; // pointer to next tile
	private String name; // name of the tile
	private boolean end = false; // true if this is the last tile(finish)
	private boolean start = false; // true if this is the first tile (start)
	// list of players who are standing on this tile
	private List<Player> players = new ArrayList();
	
	/**
	 * Tile constructor
	 * @param name of the tile
	 */
	public Tile(String name){
		this.name = name;
	}
	
	/**
	 * @return list of players standing on this tile
	 */
	public List getPlayers(){
		return players;
	}
	/**
	 * @param p player who is added to this tile
	 * @return player who was just added to this tile
	 */
	public Player addPlayer(Player p){
		players.add(p);
		return p;
	}
	/**
	 * @param p player who will be removed from this tile
	 * @return the player who was just moved :)
	 */
	public Player removePlayer(Player p){
		players.remove(p);
		return p;
	}
	

	
	/**
	 * Connects this tile to the next.
	 * @param t - next tile
	 * @return next tile(so we can connect the tiles in one row)
	 */
	public Tile connectTile(Tile t){
		this.next = t;
		return t;
	}
	/**
	 * @return name of the tile
	 */
	public String getName(){
		return name;
	}
	/**
	 * @return pointer to next room
	 */
	public Tile getNext(){
		return next;
	}
	/**
	 * True if tile is the finish
	 */
	public void setEnd(){
		end = true;
	}
	/**
	 * True if tile is the start
	 */
	public void setStart(){
		start = true;
	}
	public boolean isEnd(){
		return end;
	}
	public boolean isStart(){
		return start;
	}
	public String toString(){
		return name;
	}
}
